<?php
	if (!empty(HTTPContext::$session['client']))
	{
		//followers
		$this->data['followers'] = (!isset($this->data['followers'])) ? $this->CountFollowers(HTTPContext::$session['client']['id']) : $this->data['followers'];
	
		//client
		$this->data['client'] = $this->GetModelObject('Clients')->Get(HTTPContext::$session['client']['id']);
			
		//referrals
		if (!isset($this->data['referrals']))
		{
			$clients = $this->GetModelObject('Clients')->ListItems(array(), 'sp_clients_list_simple');
			$this->data['referrals'] = $this->CountReferrals($clients, HTTPContext::$session['client']['id']);
			$this->data['referrals'] = ($this->data['referrals'] == '') ? 0 : $this->data['referrals'];		
		}
		
		echo "
		 <!-- Menu  --> 
		 <tr class='bg_menu'>
		  	<td height='64'><img src='".SITE_IMAGES."vid.gif' alt='' /></td>
		  	<td>
		   		<table border='0' cellspacing='0' cellpadding='0' width='100%'>
		   			<tr>
		    			<td align='left'>
		      				<span class='c84 size14'>".Language::Get('Welcome').", </span>
		    				<span class='size16 tbold'>".HTTPContext::$session['client']['first_name']." ".HTTPContext::$session['client']['last_name']."</span>
		    			</td>
		    			<td align='center'>";
		    				foreach (Menus::$site_global as $key => $menu)
		    				{
		    					if (($menu['in_header'] == false) || ($menu['is_private'] == true) && (empty(HTTPContext::$session['client']))
		    						|| ($menu['is_public'] == true) && (!empty(HTTPContext::$session['client'])))
		    						{
		    							continue;
		    						}
		    					
		    					$cssClass = ($key == $this->menuItem) ? 'menu_top_sel' : '';
								echo "<div class='menu_top $cssClass'><a href='{$menu['url']}'>{$menu['text']}</a></div>";    				
		    				}
		echo " 			</td>
		    			<td align='right'>
		      				<table>
		      					<tr>
						         	<td valign='bottom'><span class='c7d size14'>".Language::Get('Referrals')." : </span><span class='size18'>{$this->data['referrals']}</span></td><td><span class='dq-icons dq-icon-human'></span></td>
						         	<td class='lpad5 rpad5'><img src='".SITE_IMAGES."l1.png' alt='' /></td>
						         	<td valign='bottom'><a href = '/clients/followers/'><span class='c7d size14'>".Language::Get('Followers')." : </span><span class=' size18'>{$this->data['followers']}</span></td><td><span class='dq-icons dq-icon-human'></span></a></td>
						         	<td class='lpad5 rpad5'><img src='".SITE_IMAGES."l1.png' alt='' /></td>
						         	<td valign='bottom'><span class='c7d size14'>".Language::Get('Money earned')." : </span><span class=' size18'>{$this->data['client']['sum']}</span></td><td><span class='dq-icons dq-icon-dollar'></span></td>
		      					</tr>
		      				</table>  
		    			</td>
		   			</tr>
		   		</table>
		  	</td>
		  	<td><img src='".SITE_IMAGES."vid.gif' alt='' /></td>
		 </tr>
		 <!-- end  Menu  -->	
		";
	}
	else 
	{
		echo "
		 <!-- Menu  --> 
		 <tr class='bg_menu'>
		  	<td height='64'><img src='".SITE_IMAGES."vid.gif' alt='' /></td>
		  	<td>
		   		<table border='0' cellspacing='0' cellpadding='0' width='100%'>
		   			<tr>
		    			<td align='center'>";
		    				foreach (Menus::$site_global as $key => $menu)
		    				{
		    					if (($menu['in_header'] == false) || ($menu['is_private'] == true) && (empty(HTTPContext::$session['client']))
		    						|| ($menu['is_public'] == true) && (!empty(HTTPContext::$session['client'])))
		    						{
		    							continue;
		    						}
		    					
		    					$cssClass = ($key == $this->menuItem) ? 'menu_top_sel' : '';
								echo "<div class='menu_top $cssClass'><a href='{$menu['url']}'>{$menu['text']}</a></div>";    				
		    				}
		    				echo "<div class='menu_top'><a href='/?login=1'>".Language::Get('Sign in')."</a></div>";    			
		echo " 			</td>
		   			</tr>
		   		</table>
		  	</td>
		  	<td><img src='".SITE_IMAGES."vid.gif' alt='' /></td>
		 </tr>
		 <!-- end  Menu  -->	
		";		
	}
?>